package light.head.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

/**
 * 企业商品展示
 */
@Entity
@Table
public class CommodityShow implements Serializable{
	private static final long serialVersionUID = -7169747211576461570L;
	private Integer code;				// 流水号
	private Integer oc;					// 公司编号
	private	Integer cc;					// 商品编号
	private String name;				// 商品名称
	private String price;				// 商品价格
	private Byte mark;					// 标记(0.无 1.新品 2.人气)
	private Integer sort;				// 展示序号
	private String sn;					// 系统生成的文件名
	private String ext;					// 后缀名
	private Integer cu;					// 创建人
	private Date ct;					// 创建日期
	private boolean deleted;			// 是否删除
	private List<CommodityShow> list;	// 批量保存
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}

	@Column
	public Integer getCc() {
		return cc;
	}

	@Column
	public Integer getOc() {
		return oc;
	}

	@Column
	public String getName() {
		return name;
	}

	@Column
	public Integer getSort() {
		return sort;
	}
	
	@Column
	public String getPrice() {
		return price;
	}
	
	@Column
	public Byte getMark() {
		return mark;
	}

	@Formula("(SELECT ci.sn FROM CommodityImg ci WHERE ci.cc = cc AND ci.cover = 1)")
	public String getSn() {
		return sn;
	}

	@Formula("(SELECT ci.ext FROM CommodityImg ci WHERE ci.cc = cc AND ci.cover = 1)")
	public String getExt() {
		return ext;
	}

	@Column
	public Integer getCu() {
		return cu;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}

	@Column
	public boolean getDeleted() {
		return deleted;
	}
	@Transient
	public List<CommodityShow> getList() {
		return list;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public void setCc(Integer cc) {
		this.cc = cc;
	}

	public void setOc(Integer oc) {
		this.oc = oc;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPrice(String price) {
		this.price = price;
	}
	
	public void setMark(Byte mark) {
		this.mark = mark;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public void setExt(String ext) {
		this.ext = ext;
	}

	public void setCu(Integer cu) {
		this.cu = cu;
	}

	public void setCt(Date ct) {
		this.ct = ct;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	
	public void setList(List<CommodityShow> list) {
		this.list = list;
	}
}
